package com.bajie.bjlisten.controller;


import com.bajie.bjlisten.api.BjSignControllerApi;
import com.bajie.bjlisten.entity.BjSign;
import com.bajie.bjlisten.entity.response.BjSignResult;
import com.bajie.bjlisten.sevice.BjSignService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/sign")
public class BjSignController implements BjSignControllerApi {

    @Autowired
    BjSignService bjSignService;

    @PostMapping(value = "/sign")
    public BjSignResult userSign(@RequestParam("userId") String userId){
        return bjSignService.userSign(userId);
    }

    @GetMapping("/30days/{userId}")
    public List<BjSign> findSign30Days(@PathVariable(value = "userId") String userId){
        return bjSignService.findSign30Days(userId);
    }

    /**
     * 根据提供的月份查询用户的签到纪录
     * @param userId
     * @param month
     * @return
     */
    @PostMapping("/signMonth")
    public BjSignResult findSignByMonth(@RequestParam("userId") String userId,@RequestParam("month") String month){
        return bjSignService.findSignByMonth(userId, month);
    }
}
